#include <iostream>
using namespace std;
#define N 501
int dp[N][N];
char v[N][N];
int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >>v[i][j];
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            int score = 0; 
            if (v[i][j] == 'l')score = 4;
            else if (v[i][j] == 'o')score = 3;
            else if (v[i][j] == 'v')score = 2;
            else if (v[i][j] == 'e')score = 1;
            dp[i][j] = max(dp[i - 1][j] + score, dp[i][j - 1] + score);
        }
    }
    printf("%d", dp[n][m]);
    return 0;
}
